define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'master/index',
                    add_url: 'master/add',
                    edit_url: 'master/edit',
                    del_url: 'master/del',
                    multi_url: '',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        {field: 'state', checkbox: true,},
                        {field: 'id', title: 'ID', operate: '='},
                        {field: 'name', title: '大师姓名', operate: 'LIKE %...%', placeholder: '关键字，模糊搜索'},
                        {field: 'details', title: '大师简介'},
                        {field: 'head', title: '头像', operate: false, formatter: Table.api.formatter.image},
                        {field: 'picture', title: '大师艺术照', operate: false, formatter: Table.api.formatter.image},
                        {field: 'teapot_pic', title: '茶壶图', operate: false, formatter: Table.api.formatter.image},
                        {field: 'process_pic', title: '制壶过程', operate: false, formatter: Table.api.formatter.image},
                        {field: 'scene_pic', title: '生活场景', operate: false, formatter: Table.api.formatter.image},
                        {field: 'pot_name', title: '茶壶名称'},
                        {field: 'pot_pic', title: '茶壶商品图', operate: false, formatter: Table.api.formatter.image},
                        {field: 'pot_size', title: '茶壶尺寸'},
                        {field: 'pot_technology', title: '茶壶工艺'},
                        {field: 'pot_capacity', title: '容量'},
                        {field: 'pot_colour', title: '釉色'},
                        {field: 'pot_mode', title: '成型方式'},
                        {field: 'pot_decorate', title: '装饰工艺'},
                        {field: 'pot_shop_url', title: '商城链接'},
                        {
                            field: 'createtime',
                            title: __('Create time'),
                            formatter: Table.api.formatter.datetime,
                            operate: 'BETWEEN',
                            type: 'datetime',
                            addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        },
                        {
                            field: 'updatetime',
                            title: __('Update time'),
                            formatter: Table.api.formatter.datetime,
                            operate: 'BETWEEN',
                            type: 'datetime',
                            addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ],
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        edit: function () {
            Form.api.bindevent($("form[role=form]"));
        },
    };
    return Controller;
});